﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using BAL.CashManagerBAL;

public partial class View_CashManager_CMHasReportOfBank : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }

    protected void grCMHRInfo_Init(object sender, System.EventArgs e)
    {
        GridFilterMenu menu = grCMHRInfo.FilterMenu;
        int i = 0;
        while (i < menu.Items.Count)
        {
            if (menu.Items[i].Text == "NoFilter")
            {
                menu.Items[i].Text = "Không lọc";
                i++;
            }
            else if (menu.Items[i].Text == "EqualTo")
            {
                menu.Items[i].Text = "Bằng";
                i++;
            }
            else if (menu.Items[i].Text == "GreaterThan")
            {
                menu.Items[i].Text = "Lớn hơn";
                i++;
            }
            else if (menu.Items[i].Text == "LessThan")
            {
                menu.Items[i].Text = "Nhỏ hơn";
                i++;
            }
            else if (menu.Items[i].Text == "GreaterThanOrEqualTo")
            {
                menu.Items[i].Text = "Lớn hơn hoặc bằng";
                i++;
            }
            else if (menu.Items[i].Text == "LessThanOrEqualTo")
            {
                menu.Items[i].Text = "Nhỏ hơn hoặc bằng";
                i++;
            }
            else
            {
                menu.Items.RemoveAt(i);
            }
        }
    }

    protected void grCMHRInfo_PreRender(object sender, EventArgs e)
    {
        HideExpandColumnRecursive(grCMHRInfo.MasterTableView);
    }

    public void HideExpandColumnRecursive(GridTableView tableView)
    {
        GridItem[] nestedViewItems = tableView.GetItems(GridItemType.NestedView);
        foreach (GridNestedViewItem nestedViewItem in nestedViewItems)
        {
            foreach (GridTableView nestedView in nestedViewItem.NestedTableViews)
            {
                if (nestedView.Items.Count == 0)
                {
                    TableCell cell = nestedView.ParentItem["ExpandColumn"];
                    cell.Controls[0].Visible = false;
                    nestedViewItem.Visible = false;
                }
                if (nestedView.HasDetailTables)
                {
                    HideExpandColumnRecursive(nestedView);
                }
            }
        }
    }

    protected void grCMHRInfo_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
    {
        CMHasReportOfBankBAL gBAL = new CMHasReportOfBankBAL();
        grCMHRInfo.DataSource = gBAL.LoadCMHasReportOfBankBAL();
    }
}